package utils;

import java.util.HashMap;
import java.util.Map;

public class Constants {

	public static Map<String, String> certPassMap = new HashMap<String, String>();
	static{
//		String tradeCustPwds = PropUtils.getProperty("TRADE_CUST_PWDS");
		
		final String custPwd = "123123";
		
//		if(StringUtils.isNotBlank(tradeCustPwds)){
//			String[] tokens = tradeCustPwds.split("\\|", -1);
//			for (int i = 1; i <= tokens.length; i++) {
//				certPassMap.put("000" + i, tokens[i - 1]);
//				certPassMap.put("300" + i, tokens[i - 1]);
//				certPassMap.put("500" + i, tokens[i - 1]);
//			}
//		}
		// 使用密码的固定写法
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				for (int k = 0; k < 10; k++) {
					certPassMap.put(i + "1" + j + k, custPwd);
				}
			}
		}
	}
	
	//p2p商户的配置
	public static String base_url = Constants.class.getResource("/").getPath();
	
	public static final String SIGN_NAME = "sign";
	public static final String BODY_NAME = "body";
	public static final String PARAM_TRANSCODE = "transCode";
	public static final String CONTEXT_NAME = "context";

	
	public static final int INTERNAL_PORT = PropUtils.getInteger("INTERNAL_PORT");
	public static final int EXTERNAL_PORT = PropUtils.getInteger("EXTERNAL_PORT");
	public static final String NET_TRADE_PLATFORM_INTERNAL_URL = PropUtils.getProperty("NET_TRADE_PLATFORM_INTERNAL_HOST") + ":" +
			PropUtils.getProperty("INTERNAL_PORT") + "/" +
			PropUtils.getProperty("NET_TRADE_PLATFORM_CONTEXT");
	public static final String NET_TRADE_PLATFORM_EXTERNAL_URL = PropUtils.getProperty("NET_TRADE_PLATFORM_EXTERNAL_HOST") + ":" +
			PropUtils.getProperty("EXTERNAL_PORT") + "/" +
			PropUtils.getProperty("NET_TRADE_PLATFORM_CONTEXT");
	public static final String NET_TRADE_PLATFORM_URL = PropUtils.getProperty("NET_TRADE_PLATFORM_URL");
//	public static final String TRADE_BANK_URL = "http://epay.cmbc.com.cn/tradeBank";
//	public static final String TRADE_BANK_URL = "http://127.0.0.1:8080/tradeBank";
	
	
	
	
	//民生平台的配置
	
	/**
	 * 证书根目录，证书名命名方式为：商户号.cer，必须包含后面斜杠
	 */
//	public static String BASE_CERT_PATH = Constants.class.getResource("/").getPath() + "/cert/";
//	public static String BASE_CERT_PATH = new DefaultResourceLoader().getResource(sm2Path);
//	public static String BASE_CERT_PATH = PropUtils.getProperty("cert_path");
//	public static String PLAT_SM2_PATH = BASE_CERT_PATH + "cmbcTest.sm2";
	public static String PLAT_SM2_PWD = PropUtils.getProperty("TRADE_SM2_PWD");
//	public static String PLAT_CERT_PATH = BASE_CERT_PATH + "cmbcTest.cer";
	
	
	/*
	 * p2p平台提交的参数名称
	 * */
	public static String PARAM_CUST_NO = "secuNo";
	public static String PARAM_CONTEXT = "context";
	public static String PARAM_SIGN = "sign";
	public static String PARAM_BODY = "body";
	
	
	/*
	 * 返回界面的参数名称
	 * */
	public static final String PARAM_RET_CODE = "retCode";
	public static final String PARAM_RET_MSG = "retMsg";
	public static final String PARAM_P2P_PLAT_NAME = "p2pPlatName";
	public static final String PARAM_COMPANY_NAME = "companyName";

	public static final String RET_SUCCESS = "0000";
	public static final String RET_FAIL = "9999";
	
	public static final String FILE_SPLIT = "#";
	public static final String FILE_UNION = "-";
	
	public static String getSm2Pass(String secuNo){
		return certPassMap.get(secuNo);
	}
}
